package net.sparrow.module;

import net.minecraft.src.EntityClientPlayerMP;
import net.sparrow.Sparrow;
import net.sparrow.cmd.CommandHandler;
import net.sparrow.event.DataField;
import net.sparrow.event.SpEventListener;
import net.sparrow.event.SpTickEvent;
import net.sparrow.util.Util;

public class SprintModule extends Module {

	@DataField( id = "player.sprint")
	public Boolean sprint = false;
	
	@SpEventListener
	public void onTick(SpTickEvent e) {
		if(!Util.inGame()) {
			return;
		}
		EntityClientPlayerMP plr = Sparrow.mc().player();
		if (plr.movementInput.moveForward < .31 || plr.isUsingItem() || !sprint || 
				plr.isSneaking() || plr.isInWater() || plr.isOnLadder() || plr.isCollidedHorizontally || plr.motionY > 0) {
			return;
		}
		plr.setSprinting(true);
	}
	
	public CommandHandler loadCommands() {
		return new CommandHandler().withDefaultToggle("player.sprint");
	}
	
}
